
package ahuy.edu.basic;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class My_textArea extends JFrame implements ActionListener{

    public static void main(String[] args) {
        My_textArea de = new My_textArea();
        de.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        de.setVisible(true);
        de.setSize(400, 300);
        JTextArea text ;
        
        JButton btn1 ;
        JButton btn2 ;
        JPanel pnmain ;
        JPanel pn1 ;
        JPanel pn2 ;
        
    }
    private Object btn1;
    public My_textArea() {
        super("Ví Dụ textArea");
        JTextArea text = new JTextArea(null, 5, 25);
        text.setLineWrap(true);
        JButton btn1 = new JButton("Nút Số 1");
        JButton btn2 = new JButton("Nút Số 2");
        JPanel pnmain = new JPanel();
        JPanel pn1 = new JPanel();
        JPanel pn2 = new JPanel();
        pnmain.setLayout(new FlowLayout());
        pn1.add(btn1);
        pn1.add(btn2);
        pnmain.add(pn2,BorderLayout.NORTH);
        pnmain.add(pn1,BorderLayout.CENTER);
        pnmain.add(text);
        btn1.addActionListener(this);
        btn2.addActionListener(this);
       
        Container con = getContentPane();
        con.add(pnmain);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource()== btn1){
                chuoi ="Xin Chào \n";
                tex
    }
        if(e.getSource()== btn2 ){
                "chuoi"+="Xin Chào \n";
    }
}

